package com.yoyo.itravel.dao;


import com.yoyo.itravel.bean.CommentReply;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.sql.SQLException;
import java.util.List;

/**
 * @Description 评论回复持久层接口
 *
 * @author HZX
 * @date 2020/5/20 22:10
 */
@Repository
public interface ICommentReplyDao {

    /**
     * @Description 插入评论回复数据
     *
     * @param commentReply
     * @return int
     */
    @Insert("insert into tb_comment_reply(replyId,content,likeNum,createTime,userId,sightCommentId,lastReplyId) " +
            "values(#{commentReply.replyId},#{commentReply.content},#{commentReply.likeNum},#{commentReply.createTime},#{commentReply.userId},#{commentReply.sightCommentId},#{commentReply.lastReplyId})")
    int insert(CommentReply commentReply) throws SQLException;

    /**
     * @Description 通过评论回复id删除评论回复数据
     *
     * @param replyId
     * @return int
     */
    @Delete("delete from tb_comment_reply where replyId=#{replyId}")
    int deleteByReplyId(String replyId) throws SQLException;

    /**
     * @Description 通过评论回复id查询评论回复数据
     *
     * @param replyId
     * @return SightCollect
     */
    @Select("select * from tb_comment_reply where replyId=#{replyId}")
    CommentReply selectByReplyId(String replyId) throws SQLException;

    /**
     * @Description 通过用户id查询该用户发表的所有的评论回复
     *
     * @param userId
     * @return java.util.List<cn.hut.travel.bean.Sight>
     */
    @Select("select * from tb_comment_reply where userId=#{userId}")
    List<CommentReply> selectAllByUserId(String userId) throws SQLException;

}
